package cn.ee.dfs.webservice.service.impl;

import cn.ee.dfs.webservice.entity.CraftInfo;
import cn.ee.dfs.webservice.entity.OrderInfo;
import cn.ee.dfs.webservice.service.DfsWebService;
import org.springframework.stereotype.Service;

import javax.jws.WebParam;
import javax.jws.WebService;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Description:
 * Created by TWJ on 2019/10/15 0015 0025 上午 10:37 .
 */
@Service
@WebService(
        targetNamespace = "dfs.ee.com", //wsdl命名空间
        serviceName = "DfsWebService",                 //portType名称 客户端生成代码时 为接口名称
        endpointInterface = "cn.ee.dfs.webservice.service.DfsWebService")//指定发布webservcie的接口类，此类也需要接入@WebService注解
public class DfsWebServiceImpl implements DfsWebService {

    @Override
    public long getTimeMillis() {
        return System.currentTimeMillis();
    }

    @Override
    public List<CraftInfo> getCraftInfoList(@WebParam(name = "count") int count) {
        count = count < 100 ? count : 100;
        List<CraftInfo> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < count; i++)
            list.add(new CraftInfo("品型号"+ random.nextInt(1000),"零件号"+ random.nextInt(1000),"零件名称"+ random.nextInt(700),
                    "零件设计版本号"+ random.nextInt(100),"工艺版本号"+ random.nextInt(100),"主制车间"+ random.nextInt(1000),
                    "承制车间"+ random.nextInt(300),"工艺有效性"+ random.nextInt(2)));
        return list;
    }

    @Override
    public List<OrderInfo> getOrderInfoList(@WebParam(name = "count") int count) {
        count = count < 100 ? count : 100;
        List<OrderInfo> list = new ArrayList<>();
        Random random = new Random();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        for (int i = 0; i < count; i++)
            list.add(new OrderInfo("订单编号"+ random.nextInt(1000),"订单类型"+ random.nextInt(10),"产品型号"+ random.nextInt(7000),"零件号"+ random.nextInt(3000),"零件名称"+ random.nextInt(100),"交付数量"+ random.nextInt(1000)
                    ,"计划开始时间"+ LocalDateTime.now().format(format),"计划完成时间"+LocalDateTime.now().format(format),"订单下达时间"+LocalDateTime.now().format(format),"订单状态"+ random.nextInt(5),"订单承接单位"+ random.nextInt(100),"入库地址"+ random.nextInt(1000)));

        return list;
    }
}